
<!--
 * @Author: Bennty
 * @Date: 2024-07-25 14:51:46
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2024-09-20 16:27:13
 * @Description: 请填写简介
-->
<template>
    <el-dialog v-model="props.visible" title="添加单号" width="20%" @close="handleClose" destory-on-close>
        <el-form :model="formData" ref="formRef">
            <el-form-item label="物流单号信息" prop="logisticsNumber">
                <el-input v-model="formData.logisticsNumber" placeholder="请输入"></el-input>
            </el-form-item>
        </el-form>
        <template #footer>
                <div class="dialog-footer">
                    <el-button  type="primary" @click="handleSubmit" >提交</el-button>
                    <el-button type="danger" @click="handleClose">关闭</el-button>
                </div>
            </template>
    </el-dialog>
</template>

<script setup lang="ts">
import type { FormInstance } from 'element-plus';
import { updateWelafareApi } from '@/api/sj/welfareExamine-crm/index';

const props = defineProps(['visible','data']);
const emits = defineEmits(['close','submit']);
const formRef = ref<FormInstance>();
const formData = ref({
    logisticsNumber: undefined
});

const handleSubmit = async () => {
    const submitData = {
        ...props.data,
        ...formData.value
    };
    const result = await updateWelafareApi(submitData);
    if(result.code == 200){
        emits('submit',true);
        handleClose();
    }else{
        emits('submit',false);
    }
};

const handleClose = ()=>{
    formRef.value?.resetFields();
    emits('close');
};
</script>

<style scoped>
.dialog-footer{
    display: flex;
    justify-content: center;
}
</style>